<?php
namespace app\mini_api\controller;

class Index extends Api
{
    public function getData()
    {
        $img = db('IndexImages')->order('sort ASC')->select();
        $images = [];
        foreach ($img as $v) {
            $row = [
                'img' => $v['url'],
                'url' => $v['pages'],
                'title' => '',
                'opentype' => 'navigate'
            ];
            $images[] = $row;
        }

        $article = db('Article')->where(['cate' => 2])->select();

        $data = [
            'swiperItems' => $images,
            'article' => $article
        ];
        $this->resSuc($data);
    }

    public function getAdList()
    {
        $data = [
            [
                'date' => '2023-6-28',
                'text' => '156****7898开通了 [套餐1]'
            ],            [
                'date' => '2023-6-28',
                'text' => '157****7898开通了 [套餐2]'
            ],            [
                'date' => '2023-6-28',
                'text' => '158****7898开通了 [套餐3]'
            ],            [
                'date' => '2023-6-28',
                'text' => '159****7898开通了 [套餐一]'
            ],            [
                'date' => '2023-6-28',
                'text' => '160****7898开通了 [套餐二]'
            ],            [
                'date' => '2023-6-28',
                'text' => '161****7898开通了 [套餐三]'
            ],
        ];

        $rows = db('AdList')->order('id DESC')->select();

        $this->resSuc($rows);
    }

}
